package spring.yongongsystem.mapper;

import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import spring.yongongsystem.POJO.dto.AdminPageQueryDTO;
import spring.yongongsystem.POJO.entity.Admin;

@Mapper
public interface AdminMapper{

    @Insert("insert into admin(username, password, status)" +
            " VALUES" +
            " (#{username},#{password},#{status})")
    void insert(Admin admin);
    /**
     * 根据用户名查询员工
     * @param username
     * @return
     */
    @Select("select * from admin where username = #{username}")
    Admin getByUsername(String username);

    /**
     * 根据id查询员工信息
     * @param id
     * @return
     */
    @Select("select * from admin where id = #{id}")
    Admin getById(Long id);

    /**
     * 分页查询
     * @param adminPageQueryDTO
     * @return
     */
    Page<Admin> pageQuery(AdminPageQueryDTO adminPageQueryDTO);

    void update(Admin admins);

    @Select("SELECT COUNT(*) FROM admin;")
    Long count();
}